import {RouteRecordRaw} from 'vue-router'
import asyncLayout from "@/views/layout/asyncDefault.vue"
import adminLayout from "@/views/layout/adminDefault.vue"
// 公共路由
export const constantRoutes: Array<RouteRecordRaw> = [
    {
        path: '/',
        redirect: '/async'
    },
    {
        path: '/noPermission',
        name: 'NoPermission',
        component: () => import('../views/error/noPermission.vue'),
        meta: {title: '无权限', icon: '', auth: []}
    },
    {
        path: '/:pathMatch(.*)',
        name: 'NotFound',
        component: () => import('../views/error/notFound.vue'),
        meta: {title: '404', icon: '', auth: []}
    }
]

// 无需权限
export const asyncRoutes: Array<RouteRecordRaw> = [
    {
        path: '/async',
        redirect: '/home',
        component: asyncLayout,
        children: [
            {
                path: '/home',
                meta: {title: '首页', routes: false, icon: 'Briefcase', auth: []},
                component: () => import('@/views/async/home/index.vue'),
                children: []
            },
            {
                path: '/monitor',
                meta: {title: '在线监测', routes: false, icon: 'Briefcase', auth: []},
                component: () => import('@/views/async/monitor/index.vue'),
                children: []
            },
            {
                path: '/gyration',
                meta: {title: '动环控制', routes: false, icon: 'Briefcase', auth: ['user']},
                component: () => import('@/views/async/gyration/index.vue'),
                children: []
            },
            {
                path: '/lock',
                meta: {title: '锁控管理', routes: false, icon: 'Briefcase', auth: ['user']},
                component: () => import('@/views/async/lock/index.vue'),
                children: []
            },
            {
                path: '/chain',
                meta: {title: '联动设置', routes: false, icon: 'Briefcase', auth: ['user']},
                component: () => import('@/views/async/chain/index.vue'),
                children: []
            },
            {
                path: '/record',
                meta: {title: '数据管理', routes: false, icon: 'Briefcase', auth: []},
                component: () => import('@/views/async/record/index.vue'),
                children: []
            },
            {
                path: '/new',
                meta: {title: '设备监控', routes: false, icon: 'Briefcase', auth: []},
                component: () => import('@/views/async/new/index.vue'),
                children: []
            },
            {
                path: '/chart',
                meta: {title: '设备详情', routes: false, icon: 'Briefcase', auth: []},
                component: () => import('@/views/async/chart/index.vue'),
                children: []
            },
            {
                path: '/alarmlog',
                meta: {title: '告警日志', routes: false, icon: 'Briefcase', auth: []},
                component: () => import('@/views/async/alarmlog/index.vue'),
                children: []
            },
            {
                path: '/measure',
                meta: {title: '数据查看', routes: false, icon: 'Briefcase', auth: []},
                component: () => import('@/views/async/measure/index.vue'),
                children: []
            },
            {
                path: '/controllog',
                meta: {title: '动环日志', routes: false, icon: 'Briefcase', auth: []},
                component: () => import('@/views/async/controllog/index.vue'),
                children: []
            },
        ]
    },
    {
        path: '/login',
        component: () => import('@/views/async/login/index.vue'),
        meta: {title: '登录', routes: false, icon: '', auth: []}
    },
    {
        path: '/test',
        component: () => import('@/views/async/test/index.vue'),
        meta: {title: '测试', routes: false, icon: '', auth: []}
    },
]

// 路由
export const adminRoutes: Array<RouteRecordRaw> = [
    {
        path: '/admin',
        redirect: '/first',
        meta: {title: '后台管理', routes: true, icon: '', auth: ['admin']},
        component: adminLayout,
        children: [
            {
                path: '/first',
                redirect: '/organ',
                meta: {title: '系统用户', routes: true, icon: 'r1', auth: ['admin']},
                children: [
                    {
                        path: '/organ',
                        meta: {title: '厂站管理', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/organ/index.vue'),
                        children: []
                    },
                    {
                        path: '/user',
                        meta: {title: '用户管理', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/user/index.vue'),
                        children: []
                    },
                    {
                        path: '/role',
                        meta: {title: '角色管理', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/role/index.vue'),
                        children: []
                    },
                ]
            },
            {
                path: '/second',
                redirect: '/sensor',
                meta: {title: '二次设备', routes: true, icon: 'r2', auth: ['admin']},
                children: [
                    {
                        path: '/sensor',
                        meta: {title: '设备管理', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/sensor/index.vue'),
                        children: []
                    },
                    {
                        path: '/alarm',
                        meta: {title: '设备告警', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/alarm/index.vue'),
                        children: []
                    },
                    {
                        path: '/action',
                        meta: {title: '设备动作', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/action/index.vue'),
                        children: []
                    },
                ]
            },
            {
                path: '/third',
                redirect: '/voltage',
                meta: {title: '一次设备', routes: true, icon: 'r3', auth: ['admin']},
                children: [
                    {
                        path: '/voltage',
                        meta: {title: '电压管理', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/voltage/index.vue'),
                        children: []
                    },
                    {
                        path: '/space',
                        meta: {title: '间隔管理', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/space/index.vue'),
                        children: []
                    },
                ]
            },
            {
                path: '/four',
                redirect: '/type',
                meta: {title: '系统设置', routes: true, icon: 'r4', auth: ['admin']},
                children: [
                    {
                        path: '/type',
                        meta: {title: '类型注册', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/type/index.vue'),
                        children: []
                    },
                    {
                        path: '/class',
                        meta: {title: '分类管理', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/class/index.vue'),
                        children: []
                    },
                    {
                        path: '/sysuse',
                        meta: {title: '系统功能', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/sysuse/index.vue'),
                        children: []
                    },
                    {
                        path: '/sysconfig',
                        meta: {title: '系统配置', routes: true, icon: 'i-ep-menu', auth: ['admin']},
                        component: () => import('../views/admin/sysconfig/index.vue'),
                        children: []
                    },
                ]
            },
        ],
    }]
